﻿using System.Collections.Generic;
using HMIS.Infrastructure.Core.Authority;
using HMIS.Infrastructure.Core.Authority.Services;
using HMIS.Infrastructure.Core.Repositories;

namespace HMIS.Infrastructure.Facade.Authority.Impl
{
	public class MenuFacadeImpl : IMenuFacade
	{
		private readonly IMenuRepository MenuRepository;
		private readonly IActionPermissionService ActionPermissionService;

		public MenuFacadeImpl(IMenuRepository MenuRepository, IActionPermissionService ActionPermissionService)
		{
			this.MenuRepository = MenuRepository;
			this.ActionPermissionService = ActionPermissionService;
		}

		#region IMenuFacade 成员

		public IList<MenuNode> GetAlllist()
		{
			return MenuRepository.GetAll();
		}

		public bool IsFieldExist(string fieldName, string fieldValue, string id)
		{
			return MenuRepository.IsFieldExist(fieldName, fieldValue, id);
		}

		public void SaveOrUpdate(MenuNode entity)
		{
			MenuRepository.SaveOrUpdate(entity);
		}

		public void Delete(string id)
		{
			MenuRepository.Delete(id);
		}

		public MenuNode Get(string id)
		{
			return MenuRepository.Get(id);
		}

		public MenuNode Load(string id)
		{
			return MenuRepository.Load(id);
		}

		public IList<ActionPermission> QueryActionPlist(string query, int start, int limit, out long total)
		{
			return ActionPermissionService.QueryActionPlist(query,start,limit,out total);
		}

		public IList<MenuNode> GetMenuListByRoleId(string roleId)
		{
			return MenuRepository.GetListByRoleId(roleId);
		}

		public IList<MenuNode> GetMenuListByUserId(string userId)
		{
			return MenuRepository.GetListByUserId(userId);
		}

		public IList<MenuNode> GetAllListByUserId(string userId)
		{
			return MenuRepository.GetAllListByUserId(userId);
		}
		
		#endregion
	}
}
